﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAL;

namespace BLL
{
   public class ClsChiTieuTinhChatVatLyBus
    {
       public ClsChiTieuTinhChatVatLyInfo Info = new ClsChiTieuTinhChatVatLyInfo();

        public DataTable SelectAll()
        {
            ClsDataAccess oConnection = new ClsDataAccess();
            string strSql = @" SELECT *FROM ChiTieuTinhChatVatLy";
            if (oConnection.ExecuteSelect(strSql))
            {
                oConnection.ODataTable.Columns.Add("STT");
                int i = 0;
                foreach (DataRow oDRow in oConnection.ODataTable.Rows)
                {
                    oDRow["STT"] = (i + 1);
                    i++;
                }
                return oConnection.ODataTable;
            }
            else return null;
        }
        public DataTable SelectMaQuyChuan()
        {
            ClsDataAccess oConnection = new ClsDataAccess();
            string strSql = @"SELECT MaQuyChuan,TenQuyChuan FROM QuyChuan";

            if (oConnection.ExecuteSelect(strSql))
            {
                return oConnection.ODataTable;
            }
            else return null;
        }
        public bool Them()
        {
            string strSql = "EXECUTE InsertChiTieuTinhChatVatLy '" + Info.MaQuyChuan + "','" + Info.NhietDo + "','" +Info.MauSac + "',N'" + Info.MuiVi + "','" + Info.DoDuc + "','" + Info.DoDanDien + "','" + Info.TDS + "','" + Info.TSS + "','" + Info.DoPhongXaAnfa + "','" + Info.DoPhongXaBeta + "'" ;
            ClsDataAccess oConnection = new ClsDataAccess();
            return (oConnection.ExecuteStoredProcedure(strSql));
        }

        public bool Sua()
        {
            string strSql = "EXECUTE UpdateChiTieuTinhChatVatLy '" + Info.MaQuyChuan + "','" + Info.NhietDo + "','" + Info.MauSac + "',N'" + Info.MuiVi + "','" + Info.DoDuc + "','" + Info.DoDanDien + "','" + Info.TDS + "','" + Info.TSS + "','" + Info.DoPhongXaAnfa + "','" + Info.DoPhongXaBeta + "'";
            ClsDataAccess oConnection = new ClsDataAccess();
            return (oConnection.ExecuteStoredProcedure(strSql));

        }

        public bool Xoa()
        {
            string strSql = "EXECUTE DeleteChiTieuTinhChatVatLy'" + Info.MaQuyChuan + "'";
            ClsDataAccess oConnection = new ClsDataAccess();
            return (oConnection.ExecuteStoredProcedure(strSql));

        }
    }
}
